/* 
 * File:   ImageFormats.h
 * Author: cow
 *
 * Created on July 28, 2011, 1:41 PM
 */

#ifndef IMAGEFORMATS_H
#define	IMAGEFORMATS_H

//Includes---------------------------------------
#include "handlers.h"
#include "../entities/unitBodies.h"
#include <string>
#include <list>
#include <cairo/cairo.h>
#include <SDL/SDL.h>
#include <string>
#include <list>
#include <SDL/SDL_image.h>
using namespace std;
//Includes=======================================

//prototypes-------------------------------------
class image;
class PNGimage;
class VECTimage;
class gridBackground;
//===============================================

//definitions------------------------------------
class image : public eventHandler, public updateHandler {
public:
	//placement---------
	image();
	virtual void draw() = 0;
	virtual void removeFrom(SDL_Surface* s);
	virtual void slide(int xDist, int yDist);
	virtual void move(int xPos, int yPos);
	//manipulators------
	void setDrawSurface(SDL_Surface* s);
	void setDrawSurface(cairo_surface_t* cs);
	void setVisible(bool vis);
	//handlers----------
	virtual bool onEvent(SDL_Event* event);
	virtual void onUpdate(float timeElapsed);
	void addEventHandler(eventHandler* e);
	void addUpdateHandler(updateHandler* u);
	void removeEventHandler(eventHandler* e);
	void removeUpdateHandler(updateHandler* u);
	//access------------
	virtual bool good();
	bool isVisible();
	int xPosition();
	int yPosition();
	virtual int width() = 0;
	virtual int height() = 0;
protected:
	//image information-
	SDL_Rect destPos;
	SDL_Surface* window;
	cairo_surface_t* cairoSurf;
	bool visible;
	//handler info------
	list<eventHandler*> eHandlerStack;
	list<updateHandler*> uHandlerStack;
};
class PNGimage : public image {
public:
	//constructors------
	PNGimage(string imageName);
	~PNGimage();
	//placement---------
	void draw();
	//access------------
	virtual bool good();
	virtual int width();
	virtual int height();
protected:
	//image information-
	string imageName;
	SDL_Surface* imageSurface;
	SDL_Rect dims;
};
class VECTimage : public image, public VectorBody {
public:
	//constructors------
	VECTimage();
	VECTimage(vector<VectorPoint*> points);
	VECTimage(list<VectorPoint*> points);
	VECTimage(VectorBody* points);
	//placement---------
	virtual void draw();
	virtual void move(int x, int y);
	virtual void slide(int x, int y);
	//access------------
	virtual bool good();
	virtual int width();
	virtual int height();
	//manipulators------
	virtual void setColor(float r, float g, float b);
	virtual void setFill(bool fill);
	//events------------
	virtual bool onEvent(SDL_Event* event);
private:
	float r, g, b;
	bool fill;
};
class gridBackground : public image {
public:
	//constructor-------
//	gridBackground(screen* sbg);
	//accesors----------
	int getLineWidth();
	int getLineHeight();
	//view manips------------
	void draw();
	//lines------------------
	void setScale(float scale);
	void setLines(int width, int height);
	void drawLines(bool lines);
	void setHighLinesDash(double* spacing, int arrSize);
	void setLineDash(double* spacing, int arrSize);
	void setHighlightLineSpacing(int spaceing);
	void setLineRGB(float R, float G, float B);
	void setHighlightLineRGB(float R, float G, float B);
private:
	//lines------------------
	bool drawlines;
	int lineWidth;
	int lineHeight;
	int highlightLine;
	double* highDash;
	int highDashSize;
	double* lowDash;
	int lowDashSize;
	//line colour------------
	float lowR;
	float lowG;
	float lowB;
	float highR;
	float highG;
	float highB;
};
//===============================================
#endif	/* IMAGEFORMATS_H */

